package l1j.opqlo.NewSystem.ItemStatus;

import l1j.server.server.model.Instance.L1ItemInstance;

public class viwerName {

	public String getViwerName(final L1ItemInstance item) {
		final StringBuilder name = new StringBuilder();

		boolean ifFH = false;

		if (item.getStunDice() != 0) {
			ifFH = true;
			name.append("昏迷+" + item.getStunDice());
		}
		if (item.getStunMr() != 0) {
			ifFH = true;
			name.append(" 抗昏迷" + item.getStunMr());
		}
		if (item.getStoneDice() != 0) {
			ifFH = true;
			name.append(" 石化+" + item.getStoneDice());
		}
		if (item.getStoneMr() != 0) {
			ifFH = true;
			name.append(" 抗石化" + item.getStoneMr());
		}
		if (item.getSleepDice() != 0) {
			ifFH = true;
			name.append(" 睡眠+" + item.getSleepDice());
		}
		if (item.getSleepMr() != 0) {
			ifFH = true;
			name.append(" 抗睡眠" + item.getSleepMr());
		}
		if (item.getSustainDice() != 0) {
			ifFH = true;
			name.append(" 支撐+" + item.getSustainDice());
		}
		if (item.getSustainMr() != 0) {
			ifFH = true;
			name.append(" 抗支撐" + item.getSustainMr());
		}
		if (item.getFreezeDice() != 0) {
			ifFH = true;
			name.append(" 冰凍+" + item.getFreezeDice());
		}
		if (item.getFreezeMr() != 0) {
			ifFH = true;
			name.append(" 抗冰凍" + item.getFreezeMr());
		}
		if (item.getBlindDice() != 0) {
			ifFH = true;
			name.append(" 黑暗+" + item.getBlindDice());
		}
		if (item.getBlindMr() != 0) {
			ifFH = true;
			name.append(" 抗黑暗" + item.getBlindMr());
		}

		if (item.getExpUp() != 0) {
			final int rate = (int) (item.getExpUp() * 100);
			name.append(" 經驗").append(rate);
			ifFH = true;
		}

		if (item.getBigDmg() != 0) {
			final int rate = item.getBigDmg();
			name.append(" 大型").append(rate);
			ifFH = true;
		}

		if (item.getSmallDmg() != 0) {
			final int rate = item.getSmallDmg();
			name.append(" 小型").append(rate);
			ifFH = true;

		}

		for (int i = 0; i <= ItemStatusName.EthnicityMax; i++) {
			if (item.getLvStatus().getEthnicityDmg(i) != 0) {
				final int rate = (int) (item.getLvStatus().getEthnicityDmg(i) * 100);
				name.append(ItemStatusName.get().getEthnicityLogName(i))
				.append(rate);
				ifFH = true;
			}
		}
		final int[] attrlist = { 1, 2, 4, 5, 6,  8 };
		for (final int element : attrlist) {
			if (item.getLvStatus().getAttrDmg(element) != 0) {
				final int rate = (int) (item.getLvStatus().getAttrDmg(element) * 100);
				name.append(ItemStatusName.get().getAttrLogNameAtk(element)).append(rate);
				ifFH = true;
			}else if(item.getLvStatus().getAttrDef().containsKey(element)){
				final int rate = (int) (item.getLvStatus().getAttrDef(element) * 100);
				if(rate >0){
					name.append(ItemStatusName.get().getAttrLogNameDef(element)).append(rate);
					ifFH = true;
				}
			}
		}

		for (int i = 0; i < 6; i++) {
			if (item.getLvStatus().getStatus(i) > 0) {
				name.append(ItemStatusName.get().getStatusLogName(i)).append(
						item.getLvStatus().getStatus(i));
				ifFH = true;
			}
		}

		if (item.getEarthMr() > 0) {
			name.append(" 地防").append(item.getEarthMr());
			ifFH = true;
		}
		if (item.getFireMr() > 0) {
			name.append(" 火防").append(item.getFireMr());
			ifFH = true;
		}
		if (item.getWaterMr() > 0) {
			name.append(" 水防").append(item.getWaterMr());
			ifFH = true;
		}
		if (item.getWindMr() > 0) {
			name.append(" 風防").append(item.getWindMr());
			ifFH = true;
		}
		if (item.getExtraDmg() > 0) {
			name.append(" 破甲").append(item.getExtraDmg());
			ifFH = true;
		}
		if (item.getExtraDef() > 0) {
			name.append(" 抵擋").append(item.getExtraDef());
			ifFH = true;
		}
		if (item.getaddSp() > 0) {
			name.append(" 魔攻").append(item.getaddSp());
			ifFH = true;
		}
		if (item.getaddMr() > 0) {
			name.append(" 魔防").append(item.getaddMr());
			ifFH = true;
		}
		if (item.getaddHp() > 0) {
			name.append(" 血量").append(item.getaddHp());
			ifFH = true;
		}
		if (item.getaddMp() > 0) {
			name.append(" 魔量").append(item.getaddMp());
			ifFH = true;
		}
		if (item.getHpr() > 0) {
			name.append(" 回血").append(item.getHpr());
			ifFH = true;
		}
		if (item.getMpr() > 0) {
			name.append(" 回魔").append(item.getMpr());
			ifFH = true;
		}
		if (item.getModHit() > 0) {
			name.append(" 命中").append(item.getModHit());
			ifFH = true;
		}
		if (item.getModDmg() > 0) {
			name.append(" 增傷").append(item.getModDmg());
			ifFH = true;
		}
		if (item.getDoubleDmg() > 0) {
			name.append(" 爆擊").append(item.getDoubleDmg());
			ifFH = true;
		}
		if (item.getMagicDmgMod() >0){
			name.append(" 法術").append(item.getMagicDmgMod());
			ifFH = true;
		}
//		if(item.getItem().getType2() == 1){
//			name.append("\r\n \\f3●5 \\f2●5 \\f4●5 \\f=●5");
//			ifFH = true;
//		}
		/** opqlo 掉寶率 */
		if(item.getItemId() != 870086){ // 聖潔聖誕襪
		final double droprate = (item.getDroprate()
				+ item.getItem().getDroprate() + item.getLvStatus().get掉寶率()) * 100;

		if (droprate != 0) {
			name.append(" 掉寶" + droprate);
		}
		}
		/** opqlo 金幣率 */
		final double moneyrate = item.getLvStatus().get金幣率() * 100;

		if (moneyrate != 0) {
			name.append(" 金幣" + moneyrate);
		}

		if (ifFH) {
			return name.toString();
		}

		return null;
	}

}
